
Public Class DAOCTHoaDOn
    Public Shared Function CTHoaDOn_Load() As DataTable
        Return DataProvider.LoadTable("Select * from CTHoaDOn")
    End Function
    'load ban an
    Public Shared Sub CTHoaDOn_Insert(ByVal n As DTOCTHoaDon)
        Dim sql As String = String.Format("insert into CTHOADON(MaHD,MaMA,TenMA,DonGia,ThanhTien,soluong) values ('{0}','{1}',N'{2}','{3}','{4}','{5}')", _
                                          n.MaHD, n.MaMA, n.TenMA, n.DonGia, n.ThanhTien, n.SoLuong)
        DataProvider.ExecuteNonQuery(sql)
    End Sub

    Public Shared Sub CTHoaDOn_Update(ByVal n As DTOCTHoaDon)
        Dim sql As String = String.Format("update CTHOADON set MaHD='{0}',MaMA='{1}',TenMA=N'{2}',DonGia='{3}',ThanhTien='{4}',soluong={6} where MaCTHD = '{5}'", _
                                          n.MaHD, n.MaMA, n.TenMA, n.DonGia, n.ThanhTien, n.MaCTHD, n.SoLuong)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
    Public Shared Sub CTHoaDOn_Delete(ByVal n As DTOCTHoaDon)
        If AgreeForm.deleteCaution = False Then
            Return
        End If
        Dim sql As String = String.Format("delete CTHoaDOn where macthd = '{0}'", n.MaCTHD)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
End Class